package cn.ecnu.auction.service;

import java.util.ArrayList;

import javax.servlet.http.HttpSession;

import org.json.JSONObject;

import cn.ecnu.auction.dao.BidDAO;
import cn.ecnu.auction.dao.UserDAO;
import cn.ecnu.auction.engine.IService;
import cn.ecnu.auction.engine.Context;
import cn.ecnu.auction.po.Bid;

public class BidService implements IService {
public void executeService(Context context) throws Exception {
		
		JSONObject requestJson = context.getJsonRequestObject();
		String operation = requestJson.getString("operation");
		int returnValue = 0;
		String jsonString = null;
		int returnCode = 0;
		
		//定义jason array
		
		if(operation.equals("add")){
			//新增出价
			int uid=requestJson.getInt("uid");
			int gid=requestJson.getInt("gid");
			double bidPrice=requestJson.getDouble("bidPrice");
			
			int result=new BidDAO().addPurchase(gid, bidPrice, uid);
			
			
			//returnValue = new UserDAO().addUser(userName, userPassword, mobile, email);
		}
		else if(operation.equals("getpurchasing")){
			//对给定用户获取他正在参与的竞拍记录
			int uid=requestJson.getInt("uid");
			
			//returnValue = new BidDAO().
			
		}
		
		
		//返回值
		JSONObject o = new JSONObject();
		o.put("returnCode", returnCode);
		o.put("returnValue", returnValue);
		//o.put("returnA");
		context.setJsonResponseObject(o);
	}
	

}
